using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using yWriter6.My.Resources;

namespace yWriter6
{
	[DesignerGenerated]
	internal class frmImportWIP : Form
	{
		private IContainer components;

		public ToolTip ToolTip1;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdCancel")]
		private Button _cmdCancel;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdOK")]
		private Button _cmdOK;

		[CompilerGenerated]
		[AccessedThroughProperty("txtWipFile")]
		private TextBox _txtWipFile;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdPickWIP")]
		private Button _cmdPickWIP;

		[CompilerGenerated]
		[AccessedThroughProperty("Label2")]
		private Label _Label2;

		[CompilerGenerated]
		[AccessedThroughProperty("Label1")]
		private Label _Label1;

		[CompilerGenerated]
		[AccessedThroughProperty("Label12")]
		private Label _Label12;

		[CompilerGenerated]
		[AccessedThroughProperty("Panel1")]
		private Panel _Panel1;

		public bool Cancelled;

		public virtual Button cmdCancel
		{
			[CompilerGenerated]
			get
			{
				return _cmdCancel;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdCancel_Click;
				Button cmdCancel = _cmdCancel;
				if (cmdCancel != null)
				{
					cmdCancel.Click -= value2;
				}
				_cmdCancel = value;
				cmdCancel = _cmdCancel;
				if (cmdCancel != null)
				{
					cmdCancel.Click += value2;
				}
			}
		}

		public virtual Button cmdOK
		{
			[CompilerGenerated]
			get
			{
				return _cmdOK;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdNext_Click;
				Button cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click -= value2;
				}
				_cmdOK = value;
				cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("txtWipFile")]
		public virtual TextBox txtWipFile
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		public virtual Button cmdPickWIP
		{
			[CompilerGenerated]
			get
			{
				return _cmdPickWIP;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdPickWIP_Click;
				Button cmdPickWIP = _cmdPickWIP;
				if (cmdPickWIP != null)
				{
					cmdPickWIP.Click -= value2;
				}
				_cmdPickWIP = value;
				cmdPickWIP = _cmdPickWIP;
				if (cmdPickWIP != null)
				{
					cmdPickWIP.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("Label2")]
		public virtual Label Label2
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label1")]
		public virtual Label Label1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label12")]
		public virtual Label Label12
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Panel1")]
		internal virtual Panel Panel1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(Disposing);
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(yWriter6.frmImportWIP));
			ToolTip1 = new System.Windows.Forms.ToolTip(components);
			cmdCancel = new System.Windows.Forms.Button();
			cmdOK = new System.Windows.Forms.Button();
			txtWipFile = new System.Windows.Forms.TextBox();
			cmdPickWIP = new System.Windows.Forms.Button();
			Label2 = new System.Windows.Forms.Label();
			Label1 = new System.Windows.Forms.Label();
			Label12 = new System.Windows.Forms.Label();
			Panel1 = new System.Windows.Forms.Panel();
			Panel1.SuspendLayout();
			SuspendLayout();
			cmdCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			cmdCancel.BackColor = System.Drawing.SystemColors.Control;
			cmdCancel.Cursor = System.Windows.Forms.Cursors.Default;
			cmdCancel.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdCancel.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdCancel.Location = new System.Drawing.Point(38, 281);
			cmdCancel.Name = "cmdCancel";
			cmdCancel.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdCancel.Size = new System.Drawing.Size(85, 43);
			cmdCancel.TabIndex = 2;
			cmdCancel.Text = "Cancel";
			cmdCancel.UseVisualStyleBackColor = true;
			cmdOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			cmdOK.BackColor = System.Drawing.SystemColors.Control;
			cmdOK.Cursor = System.Windows.Forms.Cursors.Default;
			cmdOK.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdOK.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdOK.Location = new System.Drawing.Point(519, 281);
			cmdOK.Name = "cmdOK";
			cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdOK.Size = new System.Drawing.Size(86, 43);
			cmdOK.TabIndex = 1;
			cmdOK.Text = "OK";
			cmdOK.UseVisualStyleBackColor = true;
			txtWipFile.AcceptsReturn = true;
			txtWipFile.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			txtWipFile.BackColor = System.Drawing.SystemColors.Window;
			txtWipFile.Cursor = System.Windows.Forms.Cursors.IBeam;
			txtWipFile.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			txtWipFile.ForeColor = System.Drawing.SystemColors.WindowText;
			txtWipFile.Location = new System.Drawing.Point(109, 21);
			txtWipFile.MaxLength = 0;
			txtWipFile.Name = "txtWipFile";
			txtWipFile.RightToLeft = System.Windows.Forms.RightToLeft.No;
			txtWipFile.Size = new System.Drawing.Size(441, 23);
			txtWipFile.TabIndex = 6;
			cmdPickWIP.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			cmdPickWIP.BackColor = System.Drawing.SystemColors.Control;
			cmdPickWIP.Cursor = System.Windows.Forms.Cursors.Default;
			cmdPickWIP.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdPickWIP.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdPickWIP.Location = new System.Drawing.Point(556, 19);
			cmdPickWIP.Name = "cmdPickWIP";
			cmdPickWIP.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdPickWIP.Size = new System.Drawing.Size(46, 26);
			cmdPickWIP.TabIndex = 5;
			cmdPickWIP.Text = ". . .";
			cmdPickWIP.UseVisualStyleBackColor = true;
			Label2.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			Label2.BackColor = System.Drawing.Color.Transparent;
			Label2.Cursor = System.Windows.Forms.Cursors.Default;
			Label2.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			Label2.ForeColor = System.Drawing.SystemColors.ControlText;
			Label2.Location = new System.Drawing.Point(31, 141);
			Label2.Name = "Label2";
			Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label2.Size = new System.Drawing.Size(554, 69);
			Label2.TabIndex = 9;
			Label2.Text = "To ensure the import process works properly, your chapter headings should be 'Chapter NN' (where NN is the number) and all your scene breaks should be three asterisks, spaced out: * * *";
			Label1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			Label1.BackColor = System.Drawing.Color.Transparent;
			Label1.Cursor = System.Windows.Forms.Cursors.Default;
			Label1.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			Label1.Location = new System.Drawing.Point(31, 65);
			Label1.Name = "Label1";
			Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label1.Size = new System.Drawing.Size(554, 65);
			Label1.TabIndex = 8;
			Label1.Text = resources.GetString("Label1.Text");
			Label12.BackColor = System.Drawing.Color.Transparent;
			Label12.Cursor = System.Windows.Forms.Cursors.Default;
			Label12.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			Label12.ForeColor = System.Drawing.SystemColors.ControlText;
			Label12.Location = new System.Drawing.Point(12, 24);
			Label12.Name = "Label12";
			Label12.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label12.Size = new System.Drawing.Size(91, 21);
			Label12.TabIndex = 7;
			Label12.Text = "Import File:";
			Label12.TextAlign = System.Drawing.ContentAlignment.TopRight;
			Panel1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			Panel1.BackColor = System.Drawing.Color.Transparent;
			Panel1.Controls.Add(Label1);
			Panel1.Controls.Add(txtWipFile);
			Panel1.Controls.Add(Label2);
			Panel1.Controls.Add(cmdPickWIP);
			Panel1.Controls.Add(Label12);
			Panel1.Location = new System.Drawing.Point(12, 22);
			Panel1.Name = "Panel1";
			Panel1.Size = new System.Drawing.Size(610, 230);
			Panel1.TabIndex = 10;
			base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 16f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.SystemColors.Control;
			base.ClientSize = new System.Drawing.Size(634, 336);
			base.Controls.Add(Panel1);
			base.Controls.Add(cmdCancel);
			base.Controls.Add(cmdOK);
			Cursor = System.Windows.Forms.Cursors.Default;
			DoubleBuffered = true;
			Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			base.Location = new System.Drawing.Point(3, 21);
			MinimumSize = new System.Drawing.Size(484, 370);
			base.Name = "frmImportWIP";
			RightToLeft = System.Windows.Forms.RightToLeft.No;
			Text = "Import Work In Progress";
			Panel1.ResumeLayout(false);
			Panel1.PerformLayout();
			ResumeLayout(false);
		}

		public frmImportWIP()
		{
			base.FormClosing += frmImportWIP_FormClosing;
			base.Load += frmImportWIP_Load;
			InitializeComponent();
		}

		private void cmdNext_Click(object eventSender, EventArgs eventArgs)
		{
			if (WIPOK())
			{
				Cancelled = false;
				Hide();
				cDelay.DoEvents();
			}
		}

		private void cmdPickWIP_Click(object eventSender, EventArgs eventArgs)
		{
			string filter = "Supported Formats (txt,rtf,html)|*.txt;*.rtf;*.html;*.htm";
			txtWipFile.Text = clsShared.cFileSel.AskForFilename("Select a file to import", "FileToImport.rtf", clsShared.cFile.PathOnly(txtWipFile.Text), "*.txt;*.rtf;*.html", filter);
			WIPOK();
		}

		private void frmImportWIP_FormClosing(object sender, FormClosingEventArgs e)
		{
			clsShared.cSettings.StoreWindowSettings("ImportWIP", this);
		}

		private void frmImportWIP_Load(object eventSender, EventArgs eventArgs)
		{
			base.Icon = Resources.yWriter5_Ico;
			clsSettings cSettings = clsShared.cSettings;
			Form Form = this;
			cSettings.ReadWindowSettings("ImportWIP", ref Form);
		}

		private bool WIPOK()
		{
			string left = Strings.LCase(clsShared.cFile.ExtOnly(txtWipFile.Text));
			bool flag;
			if (Operators.CompareString(Strings.Trim(txtWipFile.Text), "", TextCompare: false) == 0)
			{
				flag = false;
				clsShared.cLang.TransMsgBox("You must select an import file");
			}
			else if ((Operators.CompareString(left, "txt", TextCompare: false) != 0) & (Operators.CompareString(left, "htm", TextCompare: false) != 0) & (Operators.CompareString(left, "html", TextCompare: false) != 0) & (Operators.CompareString(left, "rtf", TextCompare: false) != 0))
			{
				clsShared.cLang.TransMsgBox("Unsupported format. Please choose a txt, rtf or html file.");
				txtWipFile.Text = "";
				flag = false;
			}
			else
			{
				flag = true;
			}
			if (flag & !clsShared.cFile.FileExists(Strings.Trim(txtWipFile.Text)))
			{
				flag = false;
				clsShared.cLang.TransMsgBox("Your import file does not exist.");
			}
			return flag;
		}

		private void cmdCancel_Click(object sender, EventArgs e)
		{
			Cancelled = true;
			Hide();
		}
	}
}
